﻿using BCCommon.OAEnums.Workflow;
using BCEntity.OA.Workflow.WorkflowActivityInstance;
using BCEntity.OA.Workflow.WorkflowActivityInstanceReference;
using BCEntity.OA.Workflow.WorkflowActivityStepExtendMethodInstance;
using BCEntity.OA.Workflow.WorkflowActivityStepInstance;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BCData.OA.Workflow.WorkflowActivityInstanceBusiness
{
    /// <summary>
    /// 工作流活动实例业务
    /// </summary>
    public interface IWorkflowActivityInstanceBusinessData
    {
        /// <summary>
        /// 创建工作流活动实例
        /// </summary>
        /// <param name="workflowActivityInstanceEntity">工作流活动实例</param>
        /// <returns></returns>
        Task<bool> Add(WorkflowActivityInstanceEntity workflowActivityInstanceEntity);
        /// <summary>
        /// 更新工作流活动实例Id
        /// </summary>
        /// <param name="workflowActivityInstanceNo">工作流活动实例编号</param>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<bool> UpdateWorkflowActivityInstanceId(string workflowActivityInstanceNo, long workflowActivityInstanceId);
        /// <summary>
        /// 更新工作流活动当前步骤下一步
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<bool> UpdateWorkflowActivityCurrentlyStepNext(long workflowActivityInstanceId);
        /// <summary>
        /// 更新工作流活动当前步骤上一步
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<bool> UpdateWorkflowActivityCurrentlyStepPrevious(long workflowActivityInstanceId);

        Task<bool> UpdateWorkflowActivityCurrentlyStepPrevious(long workflowActivityInstanceId, int currentlyStep);

        /// <summary>
        /// 获取工作流实例Id
        /// </summary>
        /// <param name="workflowActivityInstanceNo">工作流活动实例编号</param>
        /// <returns></returns>
        Task<long> GetId(string workflowActivityInstanceNo);
        /// <summary>
        /// 获取工作流实例信息
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<WorkflowActivityInstanceEntity> GetEntity(long workflowActivityInstanceId);
        /// <summary>
        /// 获取工作流实例信息（带步骤列表）
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<(IEnumerable<WorkflowActivityStepInstanceEntity>, WorkflowActivityInstanceEntity)> GetInstanceInfo(long workflowActivityInstanceId);
        /// <summary>
        /// 获取已准备就绪的工作流实例列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<WorkflowActivityInstanceEntity>> GetReadyActivity();
        /// <summary>
        /// 获取工作流步骤实例列表
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<IEnumerable<WorkflowActivityStepInstanceEntity>> GetSteps(long workflowActivityInstanceId);
        /// <summary>
        /// 获取扩展方法实例列表
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<IEnumerable<WorkflowActivityStepExtendMethodInstanceEntity>> GetExtendMethods(long workflowActivityInstanceId);

        /// <summary>
        /// 根据活动Id获取活动实例信息
        /// </summary>
        /// <param name="workflowActivityId">活动Id</param>
        /// <returns></returns>
        Task<WorkflowActivityInstanceEntity> GetByWorkflowActivityId(long workflowActivityId);

        /// <summary>
        /// 更新工作流实例状态信息
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        Task<WorkflowActivityInstanceEntity> UpdateActivityStatus(long workflowActivityInstanceId, ActivityInstanceStatus status);

        /// <summary>
        /// 获取工作流实例映射信息
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<WorkflowActivityInstanceReferenceEntity> GetActivityInstanceReferenceEntity(long workflowActivityInstanceId);

        /// <summary>
        /// 更新工作流活动到第一步
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<bool> UpdateWorkflowActivityCurrentlyStepFirst(long workflowActivityInstanceId);
        
        Task UpdateWorkflowActivityAsync(WorkflowActivityInstanceEntity workflowActivityInstance);

        /// <summary>
        /// 更新工作流实例状态信息
        /// </summary>
        /// <param name="workflowActivityInstanceIdList">工作流活动实例Id</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        Task<int> UpdateActivityStatus(List<long> workflowActivityInstanceIdList, ActivityInstanceStatus status);
    }
}
